package com.bwie.home.backstage.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.home.common.utils.PageUtils;
import com.bwie.home.common.utils.Query;

import com.bwie.home.backstage.dao.HomeDao;
import com.bwie.home.backstage.entity.HomeEntity;
import com.bwie.home.backstage.service.HomeService;


@Service("homeService")
public class HomeServiceImpl extends ServiceImpl<HomeDao, HomeEntity> implements HomeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params, HomeEntity homeEntity) {
        QueryWrapper<HomeEntity> wrapper = new QueryWrapper<>();
        if (homeEntity!=null){
            if (homeEntity.getHomeAddress()!=null && !"".equals(homeEntity.getHomeAddress())){
                wrapper.like("home_address",homeEntity.getHomeAddress());
            }
            if (homeEntity.getRent()!=null && !"".equals(homeEntity.getRent())){
                wrapper.like("rent",homeEntity.getRent());
            }
            if (homeEntity.getFloorId()!=null && !"".equals(homeEntity.getFloorId())){
                wrapper.like("floor_id",homeEntity.getFloorId());
            }
        }
        IPage<HomeEntity> page = this.page(
                new Query<HomeEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}